import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

const Home = () => import('@/pages/home/index.vue') // 首页路由
const CourseDetail = () => import('@/pages/course-detail/index.vue') // 课程详情路由
const CourseIndex = () => import('@/pages/course/index.vue') // 实战课程路由
const CourseFreeIndex = () => import('@/pages/course/index-free.vue') // 免费课程路由
const PlayIndex = () => import('@/pages/player/index.vue') // 播放页面路由
const PaySuccess = () => import('@/pages/cart/pay-success.vue') // 支付成功路由
const QuestionIndex = () => import('@/pages/question/question.vue') // 猿问路由
const QuestionDetailIndex = () => import('@/pages/question/question-detail') // 提问详情路由
const AddQuestionIndex = () => import('@/pages/add-question/index') //发布问题路由
const UserCenter = () => import('@/pages/user-center/index.vue') // 个人中心路由
const OrderIndex = () => import('@/pages/order/index.vue') // 订单中心路由
const CartIndex = () => import('@/pages/cart/confirm.vue') // 订单确认路由
const CartPay = () => import('@/pages/cart/pay.vue') // 订单支付路由
const NotFoundIndex = () => import('@/pages/404') // 404路由
const TeacherIndex = () => import('@/pages/teacher') // 讲师招募路由

const routes = [
  {
    path: '/',
    name: 'Index',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component:Home
  },
  {
    path: '/user',
    name: 'UserCenter',
    component:UserCenter,
    meta: {
      requireAuth: true,
      title: '个人中心'
    }
  },
  {
    path: '/order',
    name: 'OrderIndex',
    component:OrderIndex,
    meta: {
      requireAuth: true,
      title: '订单中心'
    }
  },
  {
    path: '/course',
    name: 'CourseIndex',
    component: CourseIndex,
    meta: {
      title: '收费课程列表'
    }
  },
  {
    path: '/free-course',
    name: 'FreeCourseIndex',
    component: CourseFreeIndex,
    meta: {
      title: '免费课程列表'
    }
  },
  {
    path: '/course/:id',
    name: 'CourseDetail',
    component: CourseDetail,
    meta: {
      title: '课程详情'
    }
  },
  {
    path: '/confirm/:courseId',
    name: 'CartIndex',
    component:CartIndex,
    meta: {
      requireAuth: true,
      title: '确认订单'
    }
  },
  {
    path: '/pay/:order',
    name: 'CartPay',
    component:CartPay,
    meta: {
      requireAuth: true,
      title: '支付中心'
    }
  },
  {
    path: '/pay/success/:order',
    name: 'PaySuccess',
    component: PaySuccess,
    meta: {
      requireAuth: true,
      title: '支付成功'
    }
  },
  {
    path: '/question',
    name: 'QuestionIndex',
    component:QuestionIndex,
    meta: {
      title: '问答中心'
    }
  },
  {
    path: '/question/:questionId',
    name: 'QuestionDetailIndex',
    component:QuestionDetailIndex,
    meta: {
      title: '问答详情'
    }
  },
  {
    path: '/wenda/add',
    name: 'AddQuestionIndex',
    component: AddQuestionIndex,
    meta: {
      requireAuth: true,
      title: '提出疑问'
    }
  },
  {
    path: '/player',
    name: 'PlayIndex',
    component: PlayIndex,
    meta: {
      requireAuth: true,
      title: '视频播放'
    }
  },
  {
    path: '/teacher',
    name: 'TeacherIndex',
    component: TeacherIndex,
    meta: {
      requireAuth: true,
      title: '讲师招募'
    }
  },
  {
    path: '/error',
    name: 'NotFoundIndex',
    component: NotFoundIndex,
    meta: {
      title: '页面走丢了'
    }
  },
  {
    path: '*',
    redirect: '/error'
  }
]
const router = new Router({
  mode: 'history',
  routes: routes,
  scrollBehavior () {
    return {
      x: 0,
      y: 0
    }
  }
})


export default router
